F/OSS Comics

8. The Origins of Unix and the C Language

Posted on Sep 4, 2023

In the 1960s, while MIT was busy developing the Incompatible Timesharing System (ITS), another place on the East Coast was buzzing with the same hacker energy: AT&T Bell Laboratories. This was where Unix and C, two creations that would change computing, were taking shape.

A programmer at MIT senses a parallel effort at Bell Labs, where two programmers work at a terminal.
MIT vs. Bell Lab.

"I sense the Force somewhere..."

ITS and Unix came from different groups. At Bell Labs, people who had worked on Multics stepped away and began building Unix. At the center of the effort were Ken Thompson, Dennis Ritchie, and Joe Ossanna.

Two Bell Labs programmers discuss Multics over cups of coffee.

"I think we need to step away from the Multics project now."
"Yeah. It's taking much longer than we expected."

The Multics project began in 1964. But as the code grew larger and more complicated, the project fell far behind Bell Labs' expectations.

A frustrated programmer grips his hair while criticizing the complexity of Multics.

"Overdesigned and overbuilt and over everything."
"It was close to unusable.[1]"

In the end, Bell Labs pulled out of Multics in 1969. Work continued elsewhere, and Multics later became a working commercial system. For Bell Labs, though, it had simply taken too long and cost too much.

A Bell Labs representative walks away while GE and MIT remain seated with a tall stack labeled Multics.

"We're leaving because we can't meet our schedule."

Back at Bell Labs, Thompson drew on his Multics experience and led the effort to build a smaller, simpler operating system.

Ken Thompson and Dennis Ritchie hold small light bulbs while discussing a simpler operating system.

"Dennis, I'm building a new operating system, taking some ideas from Multics. I'm making it smaller and simpler."
"That's a good idea. Shall I join you?"

Thompson brought several ideas from Multics into Unix, but rebuilt them in a much simpler form.

Thompson carries balloons labeled command-line interpreter, file system, and dynamic linking while Multics holds a larger cluster.

"I can't make something out of nothing."

First came a file system, sketched out by Thompson, Rudd Canaday, and Ritchie. Thompson did most of the design and put it to work on a little-used PDP-7. Ritchie added the idea of device files. Processes, utilities, and a command interpreter followed, with Ossanna and other colleagues joining in as the system grew.[2]

Thompson, Ritchie, and a colleague contribute ideas for the new file system.

"First of all, I'm working on a file system."
"We'll need a name for this thing."
"How about mapping devices to files?"

It was not called Unix at first. Well into 1970, Brian Kernighan suggested the name as a play on "Multics."

Then a PDP-11 arrived. Its CPU instructions were different from the PDP-7's, and Unix was still written in assembly. The code had to be written all over again.

Ritchie tells Thompson that a PDP-11 has arrived and suggests moving Unix to it.

"Ken, a new PDP-11 just came in. How about porting Unix to it?"
"Good idea. Trouble is, we'll have to rewrite it in PDP-11 assembly."

Thompson celebrates at a terminal while Ritchie points out the cost of repeated assembly-language ports.

"Wow, I finally finished the port!"
"But we can't rewrite Unix every time a new computer comes along."

Thompson holds a sheet marked B while considering whether the language could be used for Unix.

"Dennis, think we could rewrite Unix in B?"
"Maybe. But B still has problems on the PDP-11."

Ritchie explains that B must first work properly on the PDP-11.

"First, we'll have to make B work properly on the PDP-11."

At the time, that was easier said than done. Thompson had created B for the early Unix environment around 1969–70, building it from BCPL. It was small enough for the PDP-7, but the code it produced was much slower than assembly. B also treated everything as a machine word, which made it awkward to use on the byte-addressed PDP-11. Rewriting all of Unix in B was considered only briefly.[3]

Ritchie works at a PDP-11 terminal while describing a problem with porting B.

"First we need to port the B language to the PDP-11, but there's a problem."

In 1971, Ritchie began extending B with a character type and an explicit type system that included int and char. He also rewrote the compiler to generate PDP-11 machine code directly, instead of slower threaded code that invoked a sequence of prewritten low-level routines. He called the short-lived language NB, for "New B."[3]

Thompson asks Ritchie about the B port while Ritchie writes at a desk.

"Dennis, how's the B language porting going?"
"There are a lot of problems. B doesn't handle byte-sized characters well."

Thompson suggests rebuilding B as Ritchie considers the scale of the task.

"Why not tear B apart and fix it properly?"
"I may have to rebuild the whole thing."

So Ritchie began tearing B apart and rebuilding it. During 1972, he expanded its type system, reworked arrays and pointers, added structures, and wrote a new compiler. When the new language took shape, he called it C. Whether the name meant the letter after B or continued the letters in BCPL, Ritchie left open. By early 1973, the essentials of modern C were in place.

Thompson and Ritchie work together at the PDP-11 and agree on the name C.

"How about calling it C?"
"Sounds good"

In the summer of 1973, Thompson, Ritchie, and their colleagues rewrote the Unix kernel in C.

Ritchie types at a terminal after the Unix kernel has been rewritten without assembly language.

"Hmm. No more assembly."

Structures were especially useful. They let C describe data such as Unix directory entries in a way that matched how it was laid out in memory. Now C was powerful enough to write a Unix kernel.

A C-themed superhero lifts a UNIX sign while a smaller figure representing assembly language reacts below.

And so Unix and C came together in a remarkably short time, through the work of Thompson, Ritchie, and their Bell Labs colleagues. Unix and Unix-like systems still run on countless servers, personal computers, and phones. And C is still used to build operating-system kernels and other systems software today.

Readings from the Computer History Museum

  1. David C. Brock, the earliest unix code: an anniversary source code release, CHM

References

  1. Multics, Wikipedia
  2. Dennis M. Ritchie, The Evolution of the Unix Time-sharing System
  3. Dennis M. Ritchie, The Development of the C Language